Dashboard Temp Share Shortlinks Frames API

HTMLify

Remove duplicate elements from sorted Array.cpp
Views: 1 | Author: cody
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class Solution{
public:
    int remove_duplicate(int a[],int n){
        // code here
        int i = 0;
        for(int j =0 ; j<n; j++){
            if(a[i] != a[j]){
                a[i+1] = a[j];
                i++;
            }
        }
        return (i+1); 
    }
};